const app = getApp()

// pages/detail/detail.js
Page({
  data: {
    title: 'hello',
    list: [
      'a', 'b', 'c'
    ],
    length: 1,
    myTitle: {
      title: 'aaaabbbb'
    },
    viewtap: 'handleViewTap',
    textValue: 'username'
  },
  onLoad: function (options) {
    console.log(app.title)
    this.setData({
      title: 'world'
    })
    // this.title = 'world'



  },
  onShow() {
    console.log('onShow')
  },
  onHide() {
    console.log('onHide')
  },
  onPullDownRefresh() {
    console.log('refresh')
  },
  onReachBottom() {
    console.log('reach bottom')
  },
  onAddToFavorites(res) {
    // webview 页面返回 webviewUrl
    console.log('WebviewUrl: ', res.webviewUrl)
    return {
      title: '自定义标题',
      imageUrl: 'http://demo.png',
      query: 'name=xxx&age=xxx',
    }
  },
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: '自定义转发标题',
      path: '/page/user?id=123'
    }
  },
  onTabItemTap(obj) {
    console.log(obj)
  },

  handleTap(e) {
    // console.log(e.target.dataset)
    console.log(e.mark)

    const query = wx.createSelectorQuery()
    query.select('#btn').boundingClientRect(function(res){
      res.top // #the-id 节点的上边界坐标（相对于显示区域）
      console.log(res.top)
    })
    query.selectViewport().scrollOffset(function(res){
      res.scrollTop // 显示区域的竖直滚动位置
    })
    query.exec()
  },

  handleViewTap() {
    console.log('bubbled')
  },

  handleOuterTap () {
    console.log('outer')
  },

  handleInput(e) {
    console.log(e.detail.value)
    this.setData({
      textValue: e.detail.value
    })
  }

  // viewtap() {
  //   console.log(0)
  // }
})